/*
{
"状态":1,
"名称":"同步-钉钉部门",
"作者":"马学兵",
"创建时间":"2018-08-28",
"功能":"新增-钉钉部门",
"log": [
	{"date":"" , "dev" :"" , "content" : ""}
]
}
*/
declare @platform int , @deptid varchar(1000) , @parent varchar(100) , @name varchar(100) 
set @platform = '{platform}'
set @deptid = '{deptid}'
set  @parent = '{parent}'
set @name = '{name}'

if not exists ( select [platform_key] from [y_platform_department] where [platform_key] = @platform and [department_id] =@deptid)
begin 
	INSERT INTO [y_platform_department]([platform_key],[department_id],[department_name],[parent_id],[create_time],[update_time])
		 VALUES(@platform ,@deptid , @name ,@parent , getdate() , getdate()) 
	
end
else
begin

	UPDATE [dbo].[y_platform_department]
	   SET [department_name] = @name
		  ,[parent_id] =@parent
		  ,[update_time] = getdate() 
		where [platform_key] = @platform and [department_id] =@deptid
end





